package test.temple;

import java.util.List;
import java.util.Map;

import com.weight.common.generate.base.ResourceFile;


/**
* 
*  
*/
public class queryHtmlResourceFileNew extends ResourceFile {
	 

	private static final String FILE_NAME = ".html";
	
	public queryHtmlResourceFileNew(String filePath,String packageName,String model,List<String> fieldENList,List<String> fieldCNList,String tableCnName) {
		
		super(filePath,new StringBuilder("queryFor").append(getModelClass(model)).append("List").append(FILE_NAME).toString());
//常量		
		StringBuilder urlPath=new StringBuilder().append(packageName).append("/").append(model).append("/");//url路径
		StringBuilder beanName=getModelClass(model);//对象
		
		StringBuilder  resourceFile =new StringBuilder();
		
		resourceFile.append(" <!DOCTYPE html>\n" + 
				"<html lang=\"en\">\n" + 
				" \n" + 
				"<head>\n" + 
				"  <title>"+tableCnName+"管理</title>\n" + 
				"  <meta charset=\"utf-8\">\n" + 
				"  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n" + 
				"  <link rel=\"stylesheet\" href=\"bootstrap4/css/bootstrap.min.css\">\n" + 
				"  <link rel=\"stylesheet\" href=\"css2/style2.css\">\n" + 
				"  \n" + 
				"  <script src=\"js2/jquery.min.js\"></script>\n" + 
				"  <script src=\"js2/popper.min.js\"></script>\n" + 
				"  <script src=\"bootstrap4/js/bootstrap.min.js\"></script>\n" + 
				"</head>\n" + 
				"<script type=\"text/javascript\">\n" + 
				"//页面加载的时候,所有的复选框都是未选中的状态\n" + 
				"function checkOrCancelAll(){\n" + 
				"	//1.获取checkbo的元素对象\n" + 
				"	var chElt = $(\"#chElt\").val();\n" + 
				"	\n" + 
				"	//3.若checked=true,将所有的复选框选中,checked=false,将所有的复选框取消\n" + 
				"	var allCheck=document.getElementsByName(\"interest\");\n" + 
				"	\n" + 
				"	//4.循环遍历取出每一个复选框中的元素\n" + 
				"	//var mySpan=document.getElementById(\"mySpan\");\n" + 
				"	if(chElt == '0'){\n" + 
				"		//全选\n" + 
				"		for(var i=0;i<allCheck.length;i++){\n" + 
				"			//设置复选框的选中状态\n" + 
				"			allCheck[i].checked=true;\n" + 
				"		}\n" + 
				"		$(\"#chElt\").val(\"1\");\n" + 
				"	}else{\n" + 
				"		//取消全选\n" + 
				"		for(var i=0;i<allCheck.length;i++){\n" + 
				"			allCheck[i].checked=false;\n" + 
				"		}\n" + 
				"		$(\"#chElt\").val(\"0\")\n" + 
				"	}\n" + 
				"} \n" + 
				"</script>\n" + 
				"<body>\n" + 
				" <div class=\"header-area\" id=\"headerArea\">\n" + 
				"   <div class=\"container h-100 d-flex align-items-center justify-content-between\">\n" + 
				"     <!-- 回到首页-->\n" + 
				"     <div class=\"logo-wrapper\">\n" + 
				"     <a th:href=\"@{/setting}\"> 返回 </a>\n" + 
				"	 </div>\n" + 
				"     <!-- Search Form-->\n" + 
				"     <div class=\"top-search-form\">\n" + 
				"      	  "+tableCnName+"管理\n" + 
				"     </div>\n" + 
				"     <!-- 客户详情-->\n" + 
				"     <div class=\"suha-navbar-toggler d-flex justify-content-between flex-wrap\" id=\"suhaNavbarToggler\"><span></span><span></span><span></span></div>\n" + 
				"   </div>\n" + 
				" </div>\n" + 
				" \n" + 
				"<div id=\"wrapper\" class=\"toggled\">\n" + 
				"  <div class=\"container mt60\"  >\n" + 
				" 	<div class=\"row clearfix\">\n" + 
				"		<div class=\"col-md-12 column\">\n" + 
				"			 \n" + 
				"			<!--  \n" + 
				"			 <button type=\"button\" class=\"btn btn-default btn-success\"  onclick=\"checkOrCancelAll();\" >删除</button>\n" + 
				"			 <button type=\"button\" class=\"btn btn-default btn-success fr \"  onclick=\"checkOrCancelAll();\" >修改</button>\n" + 
				"			-->\n" + 
				"			<a th:href=\"@{"+model+"/add"+getModelClass(model)+"}\">  <button type=\"button\" class=\"btn btn-default btn-success fr mr10\"  >增加</button></a>\n" + 
				"		</div>\n" + 
				"	</div>\n" + 
				"	</div>\n" + 
				" <div class=\"container mt10\"  >\n" + 
				"	<div class=\"row clearfix\">\n" + 
				"		<div class=\"col-md-6 column\">\n" + 
				"			<table class=\"table table-striped table-bordered\">\n" + 
				"				<thead>\n" + 
				"					<tr>\n" + 
				"					    <th> \n" + 
				"						    <input type=\"hidden\" id=\"chElt\" value=\"0\"/>\n" + 
				"						    <a href=\"javascript:void(0)\" onclick=\"checkOrCancelAll();\">\n" + 
				"						    <span id=\"mySpan\">全<br/>选</span> </a>\n" + 
				"					    </th> \n" + 
				"						<th class=\"text-center\"> 序<br/>号</th> \n" );
		
				for(int i=1;i<fieldCNList.size();i++) {
					
					
					resourceFile.append("						<th>"+fieldCNList.get(i)+"</th>\n" );
					
					
				}
					resourceFile.append(	
				"					</tr>\n" + 
				"				</thead>\n" + 
				"				<tbody>\n" + 
				"					<tr th:each=\""+model+" : ${"+model+"VOList}\">\n" + 
				"					    <td><input type=\"checkbox\" name=\"interest\" th:value=\"${"+model+"."+fieldENList.get(0)+"}\"/></td>\n" + 
				"						<td><span th:text=\"${"+model+"Stat.count}\"></span></td>\n" );
				for(int i=1;i<fieldENList.size();i++) {
					
					resourceFile.append("						<td><span th:text=\"${"+model+"."+fieldENList.get(i)+"}\"></span></td>\n");
					
				}
					resourceFile.append( 
				"					</tr>					 \n" + 
				"				</tbody>\n" + 
				"			</table>\n" + 
				"		</div>\n" + 
				"	 </div>\n" + 
				"  </div>\n" + 
				"</div>\n" + 
				"</body>\n" + 
				"</html>"); 
		 
		String resource = resourceFile.toString();
		init(resource);
	}
}
